#!/usr/bin/env python
# -*- coding: utf-8 -*-
#       
#       Copyright 2010 Santiago Lezica, Juan Pablo Orsay, Facundo Martinez.
#       
#       This program is free software; you can redistribute it and/or modify
#       it under the terms of the GNU General Public License as published by
#       the Free Software Foundation; either version 2 of the License, or
#       (at your option) any later version.
#       
#       This program is distributed in the hope that it will be useful,
#       but WITHOUT ANY WARRANTY; without even the implied warranty of
#       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#       GNU General Public License for more details.
#       
#       You should have received a copy of the GNU General Public License
#       along with this program; if not, write to the Free Software
#       Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
#       MA 02110-1301, USA.

class player:
    """Player object containing all of its information"""
    def __init__(self, player_name):
        """Initializes the player object"""
        self._name = player_name
        self._score = 0
        self._available_meeples = {}
        #__init__ method not finished

    def getName(self):
        """Returns the player name"""
        return self._name

    def setName(self, player_name):
        """Sets the player name"""
        #TODO check if name is available
        self._name = player_name

    def score(self):
        """Returns the player score"""
        return self._score

    def addScore(self, a_score):
        """Adds score to the current player score"""
        #TODO Check if a_score is a valid number
        score += a_score

    def modifyMeepleQuantity(self, ammount, meeple_type="meeple"):
        """Modifies the ammount of meeples available of any kind.
            Returns False if there was an error, True if everything went O.K."""
        if meeple_type in self.available_meeples:
            if (self.available_meeples[meeple_type] + ammount) < 0:
                return False
        self.available_meeples[meeple_type] += ammount
        return True

    def getMeepleQuantity(self, meeple_type="meeple"):
        """Returns the ammount of meeple_type available, or none if
            that type doesn't exists"""
        if meeple_type in self.available_meeples:
            return self.available_meeples[meeple_type]
        return None
